﻿using System;

namespace Poly2Tri
{
	// Token: 0x0200040A RID: 1034
	public class PolygonGenerator
	{
		// Token: 0x06001CD8 RID: 7384 RVA: 0x000B3704 File Offset: 0x000B1904
		public static Polygon RandomCircleSweep(double scale, int vertexCount)
		{
			double num = scale / 4.0;
			PolygonPoint[] array = new PolygonPoint[vertexCount];
			for (int i = 0; i < vertexCount; i++)
			{
				do
				{
					if (i % 250 == 0)
					{
						num += scale / 2.0 * (0.5 - PolygonGenerator.RNG.NextDouble());
					}
					else if (i % 50 == 0)
					{
						num += scale / 5.0 * (0.5 - PolygonGenerator.RNG.NextDouble());
					}
					else
					{
						num += 25.0 * scale / (double)vertexCount * (0.5 - PolygonGenerator.RNG.NextDouble());
					}
					num = ((num <= scale / 2.0) ? num : (scale / 2.0));
					num = ((num >= scale / 10.0) ? num : (scale / 10.0));
				}
				while (num < scale / 10.0 || num > scale / 2.0);
				PolygonPoint polygonPoint = new PolygonPoint(num * Math.Cos(PolygonGenerator.PI_2 * (double)i / (double)vertexCount), num * Math.Sin(PolygonGenerator.PI_2 * (double)i / (double)vertexCount));
				array[i] = polygonPoint;
			}
			return new Polygon(array);
		}

		// Token: 0x06001CD9 RID: 7385 RVA: 0x000B3860 File Offset: 0x000B1A60
		public static Polygon RandomCircleSweep2(double scale, int vertexCount)
		{
			double num = scale / 4.0;
			PolygonPoint[] array = new PolygonPoint[vertexCount];
			for (int i = 0; i < vertexCount; i++)
			{
				do
				{
					num += scale / 5.0 * (0.5 - PolygonGenerator.RNG.NextDouble());
					num = ((num <= scale / 2.0) ? num : (scale / 2.0));
					num = ((num >= scale / 10.0) ? num : (scale / 10.0));
				}
				while (num < scale / 10.0 || num > scale / 2.0);
				PolygonPoint polygonPoint = new PolygonPoint(num * Math.Cos(PolygonGenerator.PI_2 * (double)i / (double)vertexCount), num * Math.Sin(PolygonGenerator.PI_2 * (double)i / (double)vertexCount));
				array[i] = polygonPoint;
			}
			return new Polygon(array);
		}

		// Token: 0x04001DAE RID: 7598
		private static readonly Random RNG = new Random();

		// Token: 0x04001DAF RID: 7599
		private static double PI_2 = 6.283185307179586;
	}
}
